package com.yyh.photo.controller;

import com.yyh.photo.common.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "user的接口类")
public class UserController {
//    @Autowired
//    private UserService userService;

    @GetMapping("/findById")
    @ApiOperation(value = "根据id查询")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "id", name="id",required = true),
    })
    public CommonResult findById(Integer id) {
//        User byId = userService.findById(id);
//        if (byId != null) {
            return new CommonResult(2000, "查询成功",id);
//        } else {
//            return new CommonResult(5000, "查询失败", null);
//        }
    }
//    @GetMapping("/findAll")
//    @ApiOperation(value = "查询所有")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "页码",name = "currentPage",required = true),
//            @ApiImplicitParam(value = "每页显示条数",name = "pageSize",required = true)
//    })
//    public CommonResult findAll(Integer currentPage, Integer pageSize){
//        PageInfo<User> all = userService.findAll(currentPage,pageSize);
//        if (all!=null){
//            return new CommonResult(2000,"查询成功",all);
//        }else {
//            return new CommonResult(5000,"查询失败",null);
//        }
//    }
//
//    @GetMapping("/findUpdate")
//    @ApiOperation(value = "修改操作")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "id", name="id",required = true),
//            @ApiImplicitParam(value = "账号", name="name",required = false),
//            @ApiImplicitParam(value = "密码", name="password",required = false),
//            @ApiImplicitParam(value = "真实姓名", name="realname",required = false)
//    })
//    public CommonResult findUpdate(User user){
//        int update = userService.Update(user);
//        if(update == 1){
//            return new CommonResult(2000,"修改成功",update);
//        }else {
//            return new CommonResult(5000, "修改失败", null);
//        }
//    }
//
//    @GetMapping("/findInsert")
//    @ApiOperation(value = "添加操作")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "id", name="id",required = false),
//            @ApiImplicitParam(value = "账号", name="name",required = true),
//            @ApiImplicitParam(value = "密码", name="password",required = true),
//            @ApiImplicitParam(value = "真实姓名", name="realname",required = true)
//    })
//    public CommonResult findInsert(User user){
//        int insert = userService.insert(user);
//        if(insert==1){
//            return new CommonResult(2000,"添加成功",insert);
//        }else{
//            return  new CommonResult(5000,"添加失败",null);
//        }
//    }
//    @GetMapping("/findDelete")
//    @ApiOperation(value = "删除操作")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "id", name="id",required = true),
//    })
//    public CommonResult findDelete(Integer id){
//        int delete = userService.delete(id);
//        if(delete==1){
//            return  new CommonResult(2000,"删除成功",delete);
//        }else
//        {
//            return  new CommonResult(5000,"删除失败",null);
//        }
//    }

}
